<?php
    
    class ElementTableMetadata extends Element {
        public function Render( $startrow, $numrows, $curpage ) {
            global $server, $db, $table;
            
            $numpages = ceil( $numrows / PAGE_LIMIT ); // PAGE_LIMIT: libs/baboo

            $endrow = $startrow + PAGE_LIMIT - 1; // PAGE_LIMIT: libs/baboo
            if ( $endrow > $numrows ) {
                $endrow = $numrows;
            }

            if ( $numrows == 0 || ( $numrows == 1 && $numpages == 1 ) ) {
                return false;
            }

            ?><div class="metadata" id="metadata">
                Results <span><?php
                echo $startrow;
                ?></span> - <span><?php
                echo $endrow;
                ?></span><?php
                if ( $numrows > $endrow ) {
                    ?> of about <span><?php
                    echo $numrows;
                    ?></span><?php
                }
                ?>. <span style="display: none;"><?php
                echo $curpage; // that's for js/metadata.js
                ?></span><?php
                if ( $numpages > 1 ) {
                    ?><a <?php
                    if ( $curpage > 0 ) {
                        ?>href="<?php
                        Element( 'url', $server, $db, $table, $curpage - 1 );
                        ?>"<?php
                    }
                    else {
                        ?>class="disabled"<?php
                    }
                    ?> title="<?php
                    if ( $curpage > 0 ) {
                        ?>Previous<?php
                    }
                    else {
                        ?>No previous page<?php
                    }
                    ?>"><img src="images/resultset_previous.png" alt="&lt;" /></a>
                    <a <?php
                    if ( $curpage < $numpages - 1 ) {
                        ?>href="<?php
                        Element( 'url', $server, $db, $table, $curpage + 1 );
                        ?>"<?php
                    }
                    else {
                        ?>class="disabled"<?php
                    }
                    ?> title="<?php
                    if ( $curpage < $numpages - 1 ) {
                        ?>Next<?php
                    }
                    else {
                        ?>No next page<?php
                    }
                    ?>"><img src="images/resultset_next.png" alt="&gt;" /></a> <?php
                }
            ?></div><?php
        }
    }

?>
